//
// Project: Disagreement in science: Missing women



clear all
version 15.1  



//
// set locals

// method of identifying female variable
local female "female_genderize"

// gender of author is known
local known_gender "female_genderize!=."




//
// Biorxiv

// call data
use "${data}/output/biorxiv_gender.dta", clear


 
// analysis

//
// all authors

// baseline
local i=1
local coefficients`i' "1 2"
regress `female' ib3.results_type_id if `known_gender', vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)

// subject FE
local i=2
local coefficients`i' "1 2"
regress `female' ib3.results_type_id i.subject_id if `known_gender', vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)

// subject and year FE
local i=3
local coefficients`i' "1 2"
regress `female' ib3.results_type_id i.subject_id i.year if `known_gender', vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)



//
// first author

// baseline
local i=4
local coefficients`i' "1 2"
regress `female' ib3.results_type_id if `known_gender' & author_id==1, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)


// subject FE
local i=5
local coefficients`i' "1 2"
regress `female' ib3.results_type_id i.subject_id if `known_gender' & author_id==1, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)


// subject and year FE
local i=6
local coefficients`i' "1 2"
regress `female' ib3.results_type_id i.subject_id i.year  if `known_gender' & author_id==1, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)




//
// significance stars for regressions above
forvalues j=1/6 {
	foreach k of numlist `coefficients`j'' {
		if `p`j'_`k''<0.1 & `p`j'_`k''>=0.05 {
			scalar st`j'_`k'="*"
		}
		else if `p`j'_`k''<0.05 & `p`j'_`k''>=0.01 {
			scalar st`j'_`k'="**"
		}
		else if `p`j'_`k''<0.01 & `p`j'_`k''>=0.001 {
			scalar st`j'_`k'="***"
		}
		else if `p`j'_`k''<0.001 {
			scalar st`j'_`k'="****"
		}
		else {
			scalar st`j'_`k'=""
		}
	}
}
	




